package cn.bon.common.config;

import cn.bon.common.interceptor.MybatisSelectInterceptor;
import cn.bon.common.interceptor.MybatisTimeInterceptor;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * @Author Lc_cL
 * @Date 2023/12/26
 * @Description
 */

@Configuration
public class MyBatisConfig {
    @Autowired
    SqlSessionFactory sqlSessionFactory;
    @Value("${bon.mybatis.logic-not-delete-value}")
    public String test;

    @PostConstruct
    public void addInterceptor() {
        sqlSessionFactory.getConfiguration().addInterceptor(new MybatisSelectInterceptor());
        sqlSessionFactory.getConfiguration().addInterceptor(new MybatisTimeInterceptor());
    }
}
